# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=obs-studio
pkgver=29.1.3
pkgrel=1
pkgdesc="Free and open source software for live streaming and screen recording"
url="https://obsproject.com/"
arch="all !ppc64le !riscv64" # luajit
license="GPL-2.0-or-later"
options="!check"
makedepends="
	alsa-lib-dev
	cmake
	curl-dev
	eudev-dev
	ffmpeg-dev
	fontconfig-dev
	freetype-dev
	jack-dev
	jansson-dev
	librist-dev
	libsrt-dev
	libva-glx-dev
	libx11-dev
	libxcomposite-dev
	libxinerama-dev
	libxkbcommon-dev
	luajit-dev
	mbedtls-dev
	mesa-dev
	pciutils-dev
	pipewire-dev
	pulseaudio-dev
	python3-dev
	qt6-qtbase-dev
	qt6-qtsvg-dev
	samurai
	sndio-dev
	speexdsp-dev
	swig
	v4l-utils-dev
	wayland-dev
	x264-dev
	"
subpackages="$pkgname-dev"
source="https://github.com/obsproject/obs-studio/archive/$pkgver/obs-studio-$pkgver.tar.gz
	broken-config.patch
	no-glvnd.patch
	no-werror.patch
	"

# armhf, s390x have no vlc
case $CARCH in
	armhf|s390x)
		_vlc=OFF
		;;
	*)
		makedepends="$makedepends vlc-dev"
		_vlc=ON
		;;
esac

prepare() {
	default_prepare
	# no toggle for these, but the dirs are empty by default
	# make them valid cmake subdirs that do nothing
	touch plugins/obs-browser/CMakeLists.txt
	touch plugins/obs-websocket/CMakeLists.txt
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DOBS_VERSION_OVERRIDE=$pkgver \
		-DCALM_DEPRECATION=ON \
		-DENABLE_AJA=OFF \
		-DENABLE_JACK=ON \
		-DENABLE_VLC=$_vlc
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
563a9b71ebe273b604807b9c43be8bde58fb326e8a0b741afb84a481a99176c96bf63da2aa26b6dcc026573b7fb0bf53e0a296e2db0b93c28f0d4710cd7cf019  obs-studio-29.1.3.tar.gz
b692082e7d21ccc8fc15e839821bba7b9692925a50cac7cca2769dae2592254d5ee29057b52d60d666896924e322d8b36b4a2e61446e957d3c146f032fe8cae3  broken-config.patch
b462fd7299da4d159e69130adcfcdb49c776c092419bb2cafe3c4520d122161c11137765022494f8450693f323f34082fe95674a9ee17394ca3939004847e418  no-glvnd.patch
cc582c45d85928fb400418df03b6121654cfcca206aa8c636909f0d0141b14749e8fbbb96320fbdec27b042582a96cbffd332eda685f88d28bda602d439e3d1f  no-werror.patch
"
